//
//  AlertView.m
//  MrWrite
//
//  Created by lilg on 13-8-8.
//  Copyright (c) 2013年 Founder. All rights reserved.
//

#import "AlertView.h"
#import"MBProgressHUD.h"

#define  MBProgressHUDTag               20000
#define  UIActivityIndicatorViewTag    30000

@implementation AlertView

//弹出框信息
+(void)ShowAlterViewTitle:(NSString *)title Message:(NSString *)message;
{
    UIAlertView *warnningView = [[UIAlertView alloc]initWithTitle:title message:message delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
    [warnningView show];
    [warnningView release];
}

//带有委托回调地弹出框信息
+(void)ShowAlterViewTitle:(NSString *)title Message:(NSString *)message Delegate:(id)delegate Tag:(int)tag Cancel:(NSString *)text other:(NSString *)othertext
{
    UIAlertView *warnningView = [[UIAlertView alloc]initWithTitle:title message:message delegate:delegate cancelButtonTitle:text otherButtonTitles:othertext, nil];
    warnningView.tag = tag;
    [warnningView show];
    [warnningView release];
}

//MBProgressHUD信息显示
+(void)ShowWindowMBProgressMessage:(NSString *)message OffsetX:(float)x OffsetY:(float)y
{
    UIWindow  *window = [[UIApplication sharedApplication].windows objectAtIndex:0];
    MBProgressHUD  *HUD = [[MBProgressHUD alloc]initWithWindow:window];
    if (x!=0.0||y!=0.0) {
        CGRect frame = HUD.frame;
        if (x!=0.0) frame.origin.x = x;
        if (y!=0.0) frame.origin.y = y;
        HUD.frame = frame;
    }
    HUD.tag = MBProgressHUDTag;
    HUD.labelText = message;
    HUD.labelFont=[UIFont systemFontOfSize:12];
    HUD.mode = MBProgressHUDModeCustomView;
    [window addSubview:HUD];
    [HUD show:YES];
    [HUD release];
}

//更新MBProgressHUD信息显示
+(void)ShowWindowMBProgressMessage:(NSString *)message
{
    UIWindow  *window = [[UIApplication sharedApplication].windows objectAtIndex:0];
    MBProgressHUD  *HUD = (MBProgressHUD *)[window viewWithTag:MBProgressHUDTag];
    HUD.labelText = message;
}

//MBProgressHUD隐藏
+(void)HidenMBProgressFromWindow
{
    UIWindow  *window = [[UIApplication sharedApplication].windows objectAtIndex:0];
    MBProgressHUD  *HUD = (MBProgressHUD *)[window viewWithTag:MBProgressHUDTag];
    if (HUD) {
        [HUD hide:YES];
        [HUD removeFromSuperview];
    }
}

//UIActivityIndicatorView  信息显示
+(void)ShowActivityIndicatorViewAddWindow
{
    UIWindow  *window = [[UIApplication sharedApplication].windows objectAtIndex:0];
   UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc]initWithFrame:window.bounds];
    activityView.tag=UIActivityIndicatorViewTag;
    [activityView startAnimating];
    activityView.hidesWhenStopped = YES;
    activityView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;
    [window addSubview:activityView];
    [activityView release];
}

//UIActivityIndicatorView  信息显示
+(void)HidenActivityIndicatorViewFromWindow
{
    UIWindow  *window = [[UIApplication sharedApplication].windows objectAtIndex:0];
    UIActivityIndicatorView *activityView =(UIActivityIndicatorView*) [window viewWithTag:UIActivityIndicatorViewTag];
    [activityView stopAnimating];
    [activityView removeFromSuperview];
}
@end
